package com.lz.sports.utils

import java.text.SimpleDateFormat
import java.util.*


object DateUtils {

    private val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm")

    private val dateFormat2 = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")

    @JvmStatic
    fun format(time: Long): String {
        if (time == 0L) return ""
        return try {
            dateFormat.format(Date(time))
        } catch (_: Exception) {
            ""
        }
    }

    @JvmStatic
    fun format2(time: Long): String {
        if (time == 0L) return ""
        return try {
            dateFormat2.format(Date(time))
        } catch (_: Exception) {
            ""
        }
    }

    @JvmStatic
    fun formatCurrentTime(): String {
        return try {
            dateFormat.format(Date())
        } catch (_: Exception) {
            ""
        }
    }

}